package edu.uestc.wsn;

import javax.swing.*;
import java.awt.*;
import java.util.Map;

public class RedPoint extends JFrame {
    private static Integer width = 10, height = 10;
    public static boolean showName = true;
    private Map<String, LocRss> map;

    public RedPoint(String title, Map<String, LocRss> map) {
        super(title);
        this.map = map;
    }

    public void paint(Graphics g) {
        super.paint(g);
        g.setColor(Color.RED);
        if (map.size() > 0)
            for (LocRss l : map.values()) {
                if (showName) {
                    g.setColor(Color.BLUE); //用藍色繪製節點名稱及RSS值
                    g.drawString("<" + l.getName() + "," + String.format("%.2f", l.getRss()) + ">", l.getX(), l.getY());
                }
                g.setColor(Color.RED);
                g.fillOval(l.getX(), l.getY(), toInt(width * l.getRss()), toInt(height * l.getRss()));
            }
        // g.fillOval(500, 100, 10,10);

    }

    private int toInt(Double d) {
        return d.intValue();
    }

}